<%@page import="com.team.util.ObjectUtil"%>
<%@page import="com.team.entity.Project"%>
<%@page import="com.team.util.Const"%>
<%@ page import="com.team.entity.User" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset="UTF-8" />
	<title>项目列表</title>
	 <link rel="stylesheet" href="css/prettify.css" />
    <link rel="stylesheet" href="css/bootstrap.min.css" />
	<style type="text/css" src="css/span.css"></style>
	<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body class="body">

 <c:choose>
			<c:when test="${param.code=='1001'}">
				<div style="color:red;">验证码错误</div>
			</c:when>
			<c:when test="${param.code=='1002'}">
				<div style="color:red;">请先登录</div>
			</c:when>
			<c:when test="${param.code=='1003'}">
				<div style="color:red;">此用户不存在</div>
			</c:when>
			<c:when test="${param.code=='1004'}">
				<div style="color:red;">用户名或密码错误</div>
			</c:when>
			<c:when test="${param.code=='1005'}">
				<div style="color:red;">重置失败</div>
			</c:when>
		</c:choose>
<% 
	User user = (User)session.getAttribute(Const.SESSION_USER); 
 %>
	<div class="navbar navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<a href="#" class="brand">凯盛项目管理系统</a>
				 <ul class="nav pull-right">
						<li><a class="nav pull-right" href="#">用户名：<%=user.getUsername() %></a></li>
				 </ul>
			</div>
		</div>
	</div>
  
	<div class="container">
			
		<div class="row show-grid">
		<div class="span4">
			<a href="newProj.jsp" class="btn btn-success">开始一个新项目</a>
		</div>
		<div class="span4 offset4">
			<button href="#" class="btn btn-primary">删除所有项目</button>
		</div>
	  </div>
		<%
		List<Project> list = (List<Project>)application.getAttribute(Const.APPLICATION_PROJS);
		Map<Project,User> map = (Map<Project,User>)application.getAttribute(Const.APPLICATION_ADMIN);
		if(list == null||map == null){
		 %>
		 <div style="color:red;" ><a href="newProj.jsp">没有新项目，亲，赶快来新建吧！！</a></div>
		 <%}else {
		 	for(Project proj:list){
		  %>
		 <div class="subnav">
			<ul style="margin-bottom:0px;border-radius: 3px 3px 0 0;margin-top:15px" class="breadcrumb">
				<li class="active">
					<%=proj.getId()%>
					 <a href="info.jspx?projId=<%=proj.getId()%>&_m=select "><i class="icon-th"></i><%=proj.getProjName() %> </a>
				</li>
				<li style="float:right"><i class="icon-edit"></i><a id = "red" class="link-black" href="newProj.jspx?_m=edit&projId=<%=proj.getId()%>">编辑</a></li>
				<li style="float:right"><i class="icon-trash"></i><a  id = "del"  class="link-black" rel="<%=proj.getId()%>" href="javascript:;" >删除</a></li>
				<%if(map.containsKey(proj)){ %>
				<li style="float:right"><i class="icon-user"></i><a style="color:black" href="#"><%=map.get(proj).getUsername() %></a></li>
				<%} %>
			</ul>
		</div>
		<div class="wall">
				<p><%=proj.getContent() %></p>
		</div>
		 <%}} %>
		<script type="text/javascript">
    	$(document).ready(function(){
    		$("#del").click(function(){
    			var id = $(this).attr("rel");
    			if(confirm("确定要删该项目？")) {
					window.location.href = "newProj.jspx?_m=del&projId="+id;
    			}
    			
    		});
    		
    	});
    	
    </script>
		
          
 	</div>
	
</body>
</html>